<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>示例3</title>
    <script>
    function show(){
        //获取文本框的内容
        let titleInput = document.getElementById("titleInput").value;
        console.log(titleInput)
        //写入到h1
        document.getElementById("title").innerText = titleInput;
    }
    </script>
</head>
<body>
    <input id="titleInput"/>
    <button onclick="show()">确定</button>
    <h1 id="title"></h1>
</body>
</html>